package com.alawn.framework.core.domain;

import java.io.Serializable;

import lombok.Data;

@Data
public class BaseEntity implements Serializable {
	private static final long serialVersionUID = -8774370128378359009L;

	protected Long id;

	public boolean equals(Object obj) {
		if (obj == this) {
			return true;
		}
		if ((obj instanceof BaseEntity)) {
			BaseEntity entity = (BaseEntity) obj;
			if ((entity.getId() == null) || (this.getId() == null)) {
				return false;
			}
			return entity.getId().equals(this.getId());
		}
		return false;
	}

	public int hashCode() {
		if (this.getId() == null) {
			return super.hashCode();
		}
		return this.getId().hashCode();
	}

}
